.<template>
  <el-dialog
    v-model="visible"
    :close-on-click-modal="false"
    :append-to-body="true"
    title="修改状态"
  >
    <el-form
      ref="companyInfoFormRef"
      :model="formData"
      label-width="140px"
      class="business-info"
      @submit.prevent
    >
      <el-form-item
        label="状态"
        prop="status"
      >
        <el-select
          v-model="formData.status"
          placeholder="状态"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
    </el-form>
    <template #footer>
      <div>
        <el-button
          @click="visible = false"
        >
          {{ $t('allinpay.cancel') }}
        </el-button>
        <el-button
          type="primary"
          @click="submitForm"
        >
          确认
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ElMessage } from 'element-plus'
import { toRefs } from 'vue'

const emit = defineEmits(['ok'])
const options = [
  // {
  //   value: 1,
  //   label: $t('order.pendingPayment')
  // },
  {
    value: 2,
    label: $t('order.toBeShipped')
  }
  // {
  //   value: 3,
  //   label: $t('order.pendingReceipt')
  // },
  // {
  //   value: 5,
  //   label: $t('order.successfulTransaction')
  // },
  // {
  //   value: 6,
  //   label: $t('order.transactionFailed')
  // },
  // {
  //   value: 7,
  //   label: $t('group.waitGroup')
  // }
]

const visible = ref(false)
const formData = ref({})
const orderList = ref([])
const init = (orders) => {
  visible.value = true
  formData.value.status = 2
  orderList.value = orders
}

const submitForm = () => {
  const returnUrl = import.meta.env.VITE_APP_FIND_ADDRESS
  const postData = []
  orderList.value.forEach(d => {
    postData.push({
      payType: 12,
      returnUrl,
      systemType: 1,
      orderNumbers: d.orderNumber,
      userId: d.userId
    })
  })

  http({
    url: '/platform/order/pay',
    method: 'post',
    data: postData
  }).then(res => {
    ElMessage.success('操作成功')
    visible.value = false
    emit('ok')
  })
}

defineExpose({
  init
})

</script>

<style lang="scss" scoped>

</style>
